import { resolve } from 'path';
import { Module, MiddlewareConsumer, RequestMethod } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { ConfigModule, ConfigService } from 'nestjs-config';
import { StatusMonitorModule } from 'nest-status-monitor';
import statusMonitorConfig from './config/statusMonitor';
import { LoggerMiddleware } from './common/middleware/logger.middleware';
import { SignMiddleware } from './common/middleware/sign.middleware'
import { InspectionModule } from './modules/inspection/inspection.module';
import { InspectionController } from './modules/inspection/inspection.controller';

@Module({
  imports: [
    ConfigModule.load(resolve(__dirname, 'config', '**/!(*.d).{ts,js}')),
    // TODO @nestjs/terminus almost the same
    // StatusMonitorModule.setUp(statusMonitorConfig),
    InspectionModule,
  ],
})
export class AppModule {
  configure(consumer: MiddlewareConsumer) {
    consumer.apply(LoggerMiddleware, SignMiddleware).forRoutes('*');;
  }
}
